const electron = require('electron');

require("./fileupload/uploader/handlers");
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow

const path = require('path')
const url = require('url')

const deploy = require("./h5x-deploy");
deploy.build("fileupload");

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow

function createWindow () {
  // Create the browser window.
  mainWindow = new BrowserWindow({})

  // and load the index.html of the app.

  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, 'fileupload/index.build.html'),
    protocol: 'file:',
    slashes: true
  }))

  mainWindow.maximize()

  //mainWindow.loadURL("file://fileupload/index.html");

  mainWindow.openDevTools();
  mainWindow.on('closed', function () {
    mainWindow = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', function () {
  if (mainWindow === null) {
    createWindow()
  }
})
